package com.itheima.Thraed.ThreadPrinciple;

import java.util.concurrent.locks.LockSupport;

public class demo7 {
    public static void main(String[] args) throws InterruptedException {
        test3();
    }

    private static void test3() throws InterruptedException {
        Thread t1 = new Thread(() -> {
            System.out.println("park...");
            LockSupport.park(); // 挂起当前线程，使其进入等待状态
            System.out.println("unpack");
            System.out.println("打断状态:" + Thread.interrupted());// 返回当前打断状态并清除打断标记（false）
            LockSupport.park();// false时可以继续执行打断
            System.out.println("unpark");
        });
        t1.start();

        Thread.sleep(1000);
        t1.interrupt();
    }
}
